<%
  using_object_classes = @user.classes
  available_object_classes = @user.schema.object_classes.collect(&:name)
  update_failure_id = 'object-classes-obdate-failure'
%>

<% switcher("object-classes", _("Update objectClasses")) do %>
  <table class="values form">
    <thead>
      <tr>
	<th><%= _("Use") %></th>
	<th><%= _("objectClass name") %></th>
	<th><%= _("Description") %></th>
      </tr>
    </thead>

    <tbody>
<% available_object_classes.uniq.sort.each do |object_class| -%>
      <tr class="<%= cycle('even', 'odd') %>">
	<td>
          <%= check_box_tag("object-classes[]",
                            object_class,
		            using_object_classes.include?(object_class),
		            :id => "object-class-#{object_class}",
                            :onchange => "updateAttributesForm(this.form)") %>
        </td>
	<td><%= link_to_object_class(object_class) %></td>
	<td><%=h locd_(object_class) %></td>
      </tr>
<% end -%>
    </tbody>
  </table>
  <% reset_cycle %>
<% end %>

<%= javascript_tag("function updateAttributesForm(form) {" +
                      remote_function(:update => {
                                        :success => attributes_form_id,
		      			:failure => update_failure_id,
                                      },
                                      :url => {:action => :update_object_classes,
                                               :id => @user},
                                      :with => 'Form.serialize(form)') +
                   "}") %>

<div id="<%= h(update_failure_id) %>"></div>
